package com.cloudsigns.factorymanager2.produce.presenter.produce_team;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.bean.WorkPartBean;
import com.cloudsigns.factorymanager2.produce.iview.produce_team.IWorkPartDetailView;
import com.cloudsigns.factorymanager2.produce.model.produce_team.IWorkPartDetailModel;
import com.cloudsigns.factorymanager2.produce.model.produce_team.WorkPartDetailModel;

public class WorkPartDetailPresenter {
    private IWorkPartDetailView view;
    private IWorkPartDetailModel model;
    private Handler handler = new Handler();

    public WorkPartDetailPresenter(IWorkPartDetailView view) {
        this.view = view;
        this.model = new WorkPartDetailModel();
    }

    public void workPartDetail() {
        model.workPartDetail(view.getOrderId(), view.getProductId(), view.getWorkPartId(),view.getWorkPartOrderId(), new WorkPartDetailModel.OnWorkPartDetailListener() {
            @Override
            public void workPartDetailSuccessed(final WorkPartBean workPartBean) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.workPartDetailSueecssed(workPartBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void workPartDetailFailed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.workPartDetailFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
